package com.nbicc.survey.service.impl;

import com.nbicc.parent.serivce.BaseService;
import com.nbicc.survey.mapper.MultipleSelectionTopicMapper;
import com.nbicc.survey.po.MultipleSelectionTopic;
import com.nbicc.survey.service.IMultipleSelectionTopicService;
import com.nbicc.utils.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service("MultipleSelectionTopicServiceImpl")
public class MultipleSelectionTopicServiceImpl extends BaseService implements IMultipleSelectionTopicService {

    @Autowired
    private MultipleSelectionTopicMapper multipleSelectionTopicMapper;

    @Override
    public MultipleSelectionTopic selectById(String id) {
        return multipleSelectionTopicMapper.selectById(id);
    }


    @Override
    public Integer insert(MultipleSelectionTopic multipleSelectionTopic) {
        multipleSelectionTopic.setId(ToolUtil.generateUUID32());
        multipleSelectionTopic.setCreateTime(new Date());
        return multipleSelectionTopicMapper.insert(multipleSelectionTopic);
    }

    @Transactional
    @Override
    public Integer batchInsert(List<MultipleSelectionTopic> multipleSelectionTopicList) {
        for (MultipleSelectionTopic multipleSelectionTopic : multipleSelectionTopicList) {
            insert(multipleSelectionTopic);
        }
        return 1;
    }

    @Override
    public Integer updateById(MultipleSelectionTopic multipleSelectionTopic) {
        return multipleSelectionTopicMapper.updateById(multipleSelectionTopic);
    }

    @Override
    public Integer deleteById(String id) {
        return multipleSelectionTopicMapper.deleteById(id);
    }

    @Override
    public List<MultipleSelectionTopic> selectListByQuestionnaireId(String questionnaireId) {
        return multipleSelectionTopicMapper.selectListByQuestionnaireId(questionnaireId);
    }

}
